package com.hzeport.bgs22emduty.inbound.api;

import cn.hutool.json.JSONObject;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.DutyScheduleExchangeDTO;
import com.hzeport.bgs22emduty.dto.DutydignInfoListDTO;
import com.hzeport.bgs22emduty.dto.DutydignInfoListoneDTO;
import com.hzeport.bgs22emduty.vo.DutyScheduleExchange.DutyScheduleExchangeListVO;
import com.hzeport.bgs22emduty.vo.dutydignInfo.DutydignInfoAnswerSaveVO;
import com.hzeport.bgs22emduty.vo.dutydignInfo.DutydignInfoListVO;
import com.hzeport.bgs22emduty.vo.dutydignInfo.DutydignInfoListoneVO;
import com.hzeport.bgs22emduty.vo.dutydignInfo.DutydignInfoSaveVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
////import com.hzeport.bgs22emduty.entity.DutySignInfo;
import com.hzeport.bgs22emduty.service.DutySignInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.net.URLEncoder;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2022-12-02 11:21:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dutysigninfo")
@Api(value = "dutysigninfo", tags = "签到签退管理")
@Slf4j
public class DutySignInfoController {

    @Resource
    private  DutySignInfoService dutySignInfoService;
    @Resource
    private final LoginCompoentService loginCompoentService;

    @ApiOperation(value = "签到签退查询")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public BaseResult<Page<DutydignInfoListVO>> list(@RequestBody DutydignInfoListDTO dutydignInfoListDTO){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutySignInfoService.list(dutydignInfoListDTO,userInfo);
    }

    @ApiOperation(value = "个人签到签退")
    @RequestMapping(value = "listone",method = RequestMethod.POST)
    @OperLog( systemName = "QDQT", description = "GRQD")
    public BaseResult<Page<DutydignInfoListoneVO>> listone(@RequestBody DutydignInfoListoneDTO dutydignInfoListoneDTO){
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return dutySignInfoService.listone(dutydignInfoListoneDTO,userInfo);
    }


    @ApiOperation(value = "大屏签到签退")
    @RequestMapping(value = "save",method = RequestMethod.POST)
    @OperLog(systemName = "QDQT",description = "QDBC")
    public BaseResult save(@RequestBody DutydignInfoSaveVO dutydignInfoSaveVO) throws Exception {
        return dutySignInfoService.saveData(dutydignInfoSaveVO);
    }

    @ApiOperation(value = "大屏签到-答题")
    @RequestMapping(value = "answer",method = RequestMethod.POST)
    @OperLog( systemName = "QDQT", description = "DPDT")
    public BaseResult answer(@RequestBody DutydignInfoAnswerSaveVO dutydignInfoAnswerSaveVO) throws Exception {
        return dutySignInfoService.answer(dutydignInfoAnswerSaveVO);
    }

}
